Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added kpi component to models #4

Merged
merged 6 commits into from
Jul 16, 2024

Conversation

AntonioLCM
Copy link
Contributor

Included an example in examples/iris/.

Question: Is the formatting of the output in line with what you expected? If not, please do feel free to let me know what it should look like.

@AntonioLCM
Copy link
Contributor Author

Pertains to #3

Copy link
Member

@Donnype Donnype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @AntonioLCM! The help is much appreciated.

I have some suggestions to improve the functionality and example, but the setup is good!

pydfy/models.py Outdated Show resolved Hide resolved
examples/iris/main.py Outdated Show resolved Hide resolved
pydfy/models.py Outdated Show resolved Hide resolved
pydfy/template/src/partials/kpi.html Outdated Show resolved Hide resolved
pydfy/template/src/partials/kpi.html Show resolved Hide resolved
Comment on lines 5 to 8
<div class="text-xs mb-2">{{ "Goal: {:,} ({:+.2f} %)".format(component.goal,
(component.current -
component.goal) /
component.goal * 100) }}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout looks good! While experimenting I did stumble upon a zero-division error when the target equals 0. Since this becomes tedious to code in these html templates, my suggestion would be to move this logic to a @property on the KPI called _percent for instance. Also see the _base64_data field on the Image component. Then you can access e.g. the _percent column and return "Infinity" when the target equals 0, which is how PowerBI handles it.

(Another feature you could consider adding for this use case is: a flag called use_value with default False. If True, we display the absolute difference instead of relative. This does require changing the template to handle this as well though.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I appreciate your time and suggestions. Maybe the suggested feature here could be a new issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I'll add a new issue for the suggestion.

@Donnype
Copy link
Member

Donnype commented Jul 15, 2024

As a last request: could you render and commit the new out.pdf in the iris example as well? Thanks in advance!

Copy link
Member

@Donnype Donnype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @AntonioLCM! Leaving a star would be much appreciated if you like the project. Keep an eye on the issue list if you want to stay involved 😉

@Donnype Donnype merged commit 4534c7d into BiteStreams:main Jul 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants